//Test Database
import java.sql.*;

public class TestDatabase {
	
	public static void main(String[] args) throws SQLException{
		try {
			Statement stmt;
			ResultSet rs;
			Class.forName("com.mysql.jdbc.Driver").newInstance();
			String url = "jdbc:mysql://instance10905.db.xeround.com:7414/fcsgroup2"; //Location of Database
			
			//Connect to the Database
			Connection con = DriverManager.getConnection(url,"fcsgroup2", "qwerty123");

			System.out.println("URL: " + url);
			System.out.println("Connection: " + con);
			
			String user = "zigosity";
			String pass = "qwerty123";
			
			//Get a Statement Object
			stmt = con.createStatement();
			
			String update = "SELECT Username, Password from users ORDER BY Username";
			rs = stmt.executeQuery(update);
			
			rs.next();
			
			while(!(rs.getString("Username").equals(user)))
				rs.next();
			
			if(pass.equals(rs.getString("Password")))
				System.out.println("Login Successful!");
			else
				System.out.println("Login Failed");
			//Close the connection
			con.close();
			stmt.close();
			
		}
		catch(Exception e) {
			e.printStackTrace();
		}
	}
}
